'use strict';

/**
 * @ngdoc function
 * @name jgappApp.controller:SignFootmarkCtrl
 * @description
 * # SignFootmarkCtrl
 * Controller of the jgappApp
 */
angular.module('jgappApp')
    .controller('SignFootmarkCtrl', function(ContactInfo, MapService, $scope, PagingService, $location, Util, openApi, localStorageService, $routeParams) {
        var vm = this;
        vm.UserInfo = NativeUtil.getUserInfo();
        vm.checkPoints = function(data) {
                localStorageService.set("markPonits", data.list);
                $location.path("sign/footmarkdetail");
            }
            // 查看签到地点
        vm.showPosition = function(item) {
                $location.path("attendance/show_location/" + item.lat + "/" + item.lng)
            }
            // 选择签到月份
        vm.chooseDate = function() {
            getSignLog()
        };

        var setDate = function() {
            vm.dates = []
            var date = new Date();
            vm.year = date.getFullYear();
            var curMonth = date.getMonth() + 1;
            vm.month = curMonth
            while (curMonth > 0) {
                vm.dates.push(curMonth)
                curMonth--
            }
        }
        var getSignLog = function() {
            var param = {};
            param.year = vm.year;
            param.month = vm.month;
            param.limit = 5;
            param.userId = $routeParams.userId;
            vm.taskList = new PagingService(openApi.signinLog, param);
        }
        var init = function() {
            setDate();
            getSignLog();
            ContactInfo.getDatabyUserId($routeParams.userId).then(function(data) {
                vm.UserInfo = data;
            });
        };
        init()
    });
